package da.metricscraft.information;

import java.util.ArrayList;
import java.util.HashMap;

import org.bukkit.util.Vector;
import org.w3c.dom.Document;

import da.metricscraft.threads.InformationGatherer;
import da.metricscraft.threads.InformationGatherer.Xmls;
import da.metricscraft.tools.XMLWriter;
import da.metricscraft.tools.XMLWriter.XMLData;

public class ChunkInformation implements Information {
	private String biomeName, topBlock;
	private int x, y, z, biomeId;
	public ChunkInformation(String biomeName, int biomeId, String topBlock, Vector location){
		this.biomeId = biomeId;
		this.biomeName = biomeName;
		x = (int)location.getX();
		y = (int)location.getY();
		z = (int)location.getZ();
		this.topBlock = topBlock;
	}
	@Override
	public void process(InformationGatherer ig) {
		Document doc = ig.getXML(Xmls.BIOMES);
		HashMap<String, ArrayList<XMLData>> param = new HashMap<String, ArrayList<XMLData>>();
		ArrayList<XMLData> map = new ArrayList<XMLData>();
		map.add(new XMLData("x", x + ""));
		map.add(new XMLData("y", y + ""));
		map.add(new XMLData("z", z + ""));
		map.add(new XMLData("type", this.topBlock));
		param.put("topblock", map);
		XMLWriter.write(doc, param, biomeId, biomeName);
	}

}
